<template>
  <div class="app-container">
    <el-container style="height: 900px; border: 1px solid #eee; ">
      <el-aside width="250px" style="padding-left: 5px;padding-right: 5px;overflow: auto !important;">
        <!--分类树视图-->
        <zhai-tree @getNodeClick="treeHandler" ref="zhaiTree"></zhai-tree>
      </el-aside>
      <el-main>
        <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
          <el-form-item label="项目名称" prop="itemName">
            <el-input
              v-model="item.name"
              clearable
              size="small"
              :disabled="true"
            />
          </el-form-item>
          <el-form-item label="楼号" prop="floorId">
            <el-select v-model="queryParams.floorId" placeholder="请选择楼号" clearable size="small">
              <el-option
                v-for="dict in floorList"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="费用类型" prop="feeType">
            <el-select v-model="queryParams.feeType" placeholder="请选择费用类型" clearable size="small">
              <el-option
                v-for="dict in dict.type.fee_type"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          </el-form-item>
        </el-form>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              plain
              icon="el-icon-plus"
              size="mini"
              @click="handleAdd('0')"
              :disabled="btnStatus"
              v-hasPermi="['feesys:feeinfo:add']"
            >成本预测</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="primary"
              plain
              icon="el-icon-plus"
              size="mini"
              @click="handleAdd('1')"
              :disabled="btnStatus"
              v-hasPermi="['feesys:feeinfo:add']"
            >实际费用</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="primary"
              plain
              icon="el-icon-plus"
              size="mini"
              @click="handleAdd('2')"
              :disabled="btnStatus"
              v-hasPermi="['feesys:feeinfo:add']"
            >工程预算</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="danger"
              plain
              icon="el-icon-delete"
              size="mini"
              :disabled="multiple"
              @click="handleDelete"
              v-hasPermi="['feesys:feeinfo:remove']"
            >删除</el-button>
          </el-col>

          <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>
        <el-table v-loading="loading" :data="feeinfoList" @selection-change="handleSelectionChange">
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column label="类目名称" align="center" prop="categoryName" />
          <el-table-column label="楼号" align="center" prop="floorName" />
          <el-table-column label="费用类型" align="center" prop="feeType">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.fee_type" :value="scope.row.feeType"/>
            </template>
          </el-table-column>
          <el-table-column label="工程预算" align="center">
            <el-table-column label="单价" align="center" prop="ysPrice"/>
            <el-table-column label="工程量" align="center" prop="ysNum"/>
            <el-table-column label="合计" align="center" prop="ysTotal"/>
          </el-table-column>
          <el-table-column label="成本预算/实际费用" align="center">
            <el-table-column label="详细部位" align="center" prop="detailBody" />
            <el-table-column label="项目特征" align="center" prop="featureDes" />
            <el-table-column label="单位" align="center" prop="unitId">
              <template slot-scope="scope">
                <dict-tag :options="dict.type.unit_type" :value="scope.row.unitId"/>
              </template>
            </el-table-column>
            <el-table-column label="人工费" align="center">
              <el-table-column label="单价" align="center" prop="laborPrice" >
                <template slot-scope="scope">
                  <span v-if="scope.row.feeType!='2'">{{scope.row.laborPrice}}</span>
                </template>
              </el-table-column>
              <el-table-column label="工程量" align="center" prop="laborNum" >
                <template slot-scope="scope">
                  <span v-if="scope.row.feeType!='2'">{{scope.row.laborNum}}</span>
                </template>
              </el-table-column>
              <el-table-column label="小计" align="center" prop="laborTotal">
                <template slot-scope="scope">
                  <span v-if="scope.row.feeType!='2'">{{scope.row.laborTotal}}</span>
                </template>
              </el-table-column>
            </el-table-column>
            <el-table-column label="材料费" align="center">
              <el-table-column label="单价" align="center" prop="materialPrice" />
              <el-table-column label="工程量" align="center" prop="materialNum" />
              <el-table-column label="小计" align="center" prop="materialTotal" />
            </el-table-column>
            <el-table-column label="机械费" align="center">
              <el-table-column label="单价" align="center" prop="machineryPrice" />
              <el-table-column label="工程量" align="center" prop="machineryNum" />
              <el-table-column label="小计" align="center" prop="machineryTotal" />
            </el-table-column>
            <el-table-column label="综合合计" align="center" prop="totalAmount">
              <template slot-scope="scope">
                <span v-if="scope.row.feeType!='2'">{{scope.row.totalAmount}}</span>
              </template>
            </el-table-column>
            <el-table-column label="备注" align="center">
              <el-table-column label="1%发票费" align="center" prop="bill1" />
              <el-table-column label="3%发票费" align="center" prop="bill3" />
              <el-table-column label="6%发票费" align="center" prop="bill6" />
              <el-table-column label="9%发票费" align="center" prop="bill9" />
              <el-table-column label="13%发票" align="center" prop="bill13" />
              <el-table-column label="普票" align="center" prop="bill" />
            </el-table-column>
          </el-table-column>
          <el-table-column label="操作" width="110px;" align="center" class-name="small-padding fixed-width" fixed="right">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleUpdate(scope.row)"
                v-hasPermi="['feesys:feeinfo:edit']"
              >修改</el-button>
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="uploadFile(scope.row)"
              >附件</el-button>
            </template>
          </el-table-column>
        </el-table>
        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </el-main>
    </el-container>

    <!-- 添加或修改费用管理对话框 -->
    <el-dialog :title="title" :visible.sync="open" :rules="rules" width="1000px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-row>
          <el-col :span="6">
            <el-form-item label="类目名称" prop="categoryName">
              <el-input v-model="form.categoryName" placeholder="请输入类目名称" :disabled="true"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="费用类型" prop="feeType">
              <el-select v-model="form.feeType" placeholder="请选择费用类型" clearable size="small" :disabled="true">
                <el-option
                  v-for="dict in dict.type.fee_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="所属楼号" prop="floorId">
              <el-select v-model="form.floorId" placeholder="请选择楼号" clearable size="small">
                <el-option
                  v-for="dict in floorList"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6" v-if="form.feeType!='2'">
            <el-form-item label="详细部位" prop="detailBody">
              <el-input v-model="form.detailBody" type="text" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
        </el-row>
        <div v-if="form.feeType=='2'">
          <el-row>
            <el-col :span="6">
              <el-form-item label="单价" prop="laborPrice">
                <el-input v-model="form.ysPrice" type="number" placeholder="请输入工程预算" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="工程量" prop="laborNum">
                <el-input v-model="form.ysNum" type="number" placeholder="请输入工程量" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="综合合计" prop="totalAmount">
                <el-input v-model="ysTotal" placeholder="请输入综合合计" :disabled="true" />
              </el-form-item>
            </el-col>
          </el-row>
        </div>
        <div  v-if="form.feeType!='2'">
          <el-row>
            <el-col :span="6">
              <el-form-item label="综合报价" prop="isAllPrice">
                <el-radio-group v-model="form.isAllPrice">
                  <el-radio :label="0">否</el-radio>
                  <el-radio :label="1">是</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
          <template v-if="form.isAllPrice==0">
            <el-row>
              <el-col :span="24">
                <el-form-item label="项目特征描述" prop="featureDes">
                  <el-input v-model="form.featureDes" type="text" placeholder="请输入内容" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="6">
                <el-form-item label="单位" prop="unitId">
                  <el-select v-model="form.unitId" placeholder="请选择单位">
                    <el-option
                      v-for="dict in dict.type.unit_type"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="人工单价" prop="laborPrice">
                  <el-input v-model="form.laborPrice" type="number" placeholder="请输入人工单价" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="人工工程量" prop="laborNum">
                  <el-input v-model="form.laborNum" type="number" placeholder="请输入人工工程量" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="人工小计" prop="laborTotal">
                  <el-input v-model="laborTotal" type="number" placeholder="请输入人工小计" :disabled="true"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="6">
                <el-form-item label="单位" prop="unitId">
                  <el-select v-model="form.materialUnitId" placeholder="请选择单位">
                    <el-option
                      v-for="dict in dict.type.unit_type"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="材料单价" prop="materialPrice">
                  <el-input v-model="form.materialPrice" type="number" placeholder="请输入材料单价" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="材料工程量" prop="materialNum">
                  <el-input v-model="form.materialNum" type="number" placeholder="请输入材料工程量" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="材料小计" prop="materialTotal">
                  <el-input v-model="materialTotal" placeholder="请输入材料小计"  :disabled="true"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="6">
                <el-form-item label="单位" prop="unitId">
                  <el-select v-model="form.machineryUnitId" placeholder="请选择单位">
                    <el-option
                      v-for="dict in dict.type.unit_type"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="机械单价" prop="machineryPrice">
                  <el-input v-model="form.machineryPrice" type="number" placeholder="请输入机械单价" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="机械工程量" prop="machineryNum">
                  <el-input v-model="form.machineryNum" type="number" placeholder="请输入机械工程量" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="机械小计" prop="machineryTotal">
                  <el-input v-model="machineryTotal" placeholder="请输入机械小计" :disabled="true"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8">
                <el-form-item label="综合合计" prop="totalAmount">
                  <el-input v-model="totalAmount" placeholder="请输入综合合计" :disabled="true" />
                </el-form-item>
              </el-col>
            </el-row>
          </template>
          <template v-if="form.isAllPrice==1">
            <el-row>
              <el-col :span="8">
                <el-form-item label="单价" prop="allPrice">
                  <el-input v-model="form.allPrice" type="number" placeholder="请输入单价" />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="工程量" prop="allNum">
                  <el-input v-model="form.allNum" type="number" placeholder="请输入工程量"/>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="总价费用" prop="allTotal">
                  <el-input v-model="allTotal" placeholder="请输入综合合计" :disabled="true" />
                </el-form-item>
              </el-col>
            </el-row>
          </template>
          <el-row>
            <el-col :span="8">
              <el-form-item label="1%发票费" prop="bill1">
                <el-input v-model="form.bill1" type="number" placeholder="请输入1%发票费" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="3%发票费" prop="bill3">
                <el-input v-model="form.bill3" type="number" placeholder="请输入3%发票费" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="6%发票费" prop="bill6">
                <el-input v-model="form.bill6" type="number" placeholder="请输入6%发票费" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="9%发票费" prop="bill9">
                <el-input v-model="form.bill9" type="number" placeholder="请输入9%发票费" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="13%发票费" prop="bill13">
                <el-input v-model="form.bill13" type="number" placeholder="请输入13%发票费" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="普票费" prop="bill">
                <el-input v-model="form.bill" type="number" placeholder="请输入普票费" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="类目备注" prop="featureDes">
                <el-alert
                  :title="categoryRemark"
                  :closable="false"
                  type="error">
                </el-alert>
              </el-form-item>
            </el-col>
          </el-row>
        </div>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <el-drawer
      title="附件管理"
      :visible.sync="uploadFileDrawer"
      :size="450"
      direction="rtl">
      <el-upload
        ref="upload"
        :limit="5"
        :action="upload.url"
        :headers="upload.headers"
        :file-list="upload.fileList"
        :on-progress="handleFileUploadProgress"
        :on-remove="handleRemove"
        :on-preview="handlePreview"
        :on-success="handleFileSuccess"
        :auto-upload="false">
        <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
        <el-button style="margin-left: 10px;" size="small" type="success" :loading="upload.isUploading" @click="submitUpload">上传到服务器</el-button>
        <div slot="tip" class="el-upload__tip">文件大小不能超过10M</div>
      </el-upload>
    </el-drawer>


  </div>
</template>

<script>
import { listFeeinfo, getFeeinfo, delFeeinfo, addFeeinfo, updateFeeinfo, exportFeeinfo,getItem,getFloorList } from "@/api/feesys/feeinfo";
import { listFileinfo,deleteFile} from "@/api/feesys/fileinfo";
import ZhaiTree from '@/components/ZhaiTree'
import { getToken } from "@/utils/auth";
export default {
  name: "Feeinfo",
  dicts: ['fee_type', 'unit_type'],
  components: {
    ZhaiTree
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 费用管理表格数据
      feeinfoList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      floorList:[],
      item:{},
      btnStatus:true,
      uploadFileDrawer:false,
      category:null,
      // 上传参数
      upload: {
        // 是否禁用上传
        isUploading: false,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/feesys/fileinfo/upload/",
        // 上传的文件列表
        fileList: []
      },
      categoryRemark:"测试备注",
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        itemId: null,
        itemName: null,
        categoryId: null,
        categoryName: null,
        ancestors: null,
        floorId: null,
        floorName: null,
        feeType: null,
        detailBody: null,
        featureDes: null,
        unitId: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        floorId: [
          { required: true, message: "请选择楼号", trigger: "blur" }
        ]
      }
    };
  },
  computed:{
    laborTotal:function (){
      return (this.form.laborPrice*this.form.laborNum).toFixed(2);
    },
    materialTotal:function(){
      return (this.form.materialPrice*this.form.materialNum).toFixed(2);
    },
    machineryTotal:function(){
      return (this.form.machineryPrice*this.form.machineryNum).toFixed(2);
    },
    totalAmount:function(){
      return this.laborTotal*1+this.materialTotal*1+this.machineryTotal*1;
    },
    ysTotal:function (){
      return (this.form.ysPrice*this.form.ysNum).toFixed(2);
    },
    allTotal:function (){
      return (this.form.allPrice*this.form.allNum).toFixed(2);
    }
  },
  created() {
    this.getItem();
  },
  methods: {
    getBtnStatus(){
      if(this.form.itemId&&this.form.categoryId){
        this.btnStatus=false;
      }else{
        this.btnStatus=true;
      }
    },
    /** 查询费用管理列表 */
    getList() {
      this.loading = true;
      listFeeinfo(this.queryParams).then(response => {
        this.feeinfoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    getItem(){
      getItem().then(response => {
        this.item=response.data;
        this.queryParams.itemId=this.item.id;
        this.form.itemId=this.item.id;
        this.form.itemName=this.item.name;
        this.getBtnStatus();
        let obj={};
        obj.itemId=response.data.id;
        obj.status=0;
        this.getFloorList(obj);
        this.getList();
        //获取树结构
        this.$refs.zhaiTree.getTreeselect(response.data.id)
      })
    },
    getFloorList(obj){
      getFloorList(obj).then(response => {
        this.floorList=response.data;
      })
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        itemId: this.form.itemId,
        itemName: this.form.itemName,
        categoryId: this.form.categoryId,
        categoryName: this.form.categoryName,
        ancestors: null,
        floorId: null,
        floorName: null,
        feeType: null,
        detailBody: null,
        featureDes: null,
        unitId: null,
        materialUnitId: null,
        machineryUnitId: null,
        laborPrice: null,
        laborNum: null,
        laborTotal: this.laborPrice*this.laborNum,
        materialPrice: null,
        materialNum: null,
        materialTotal: null,
        machineryPrice: null,
        machineryNum: null,
        machineryTotal: null,
        totalAmount: null,
        ysPrice:null,
        ysNum:null,
        ysTotal:null,
        bill1: null,
        bill3: null,
        bill6: null,
        bill9: null,
        bill13: null,
        bill: null,
        isAllPrice:0,
        allPrice:null,
        allNum:null,
        allTotal:null,
        status: "0",
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd(feeType) {
      this.reset();
      this.form.feeType=feeType;
      this.open = true;
      this.title = "添加费用管理";
      this.initForm(feeType);
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getFeeinfo(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改费用管理";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        this.form.laborTotal=this.laborTotal;
        this.form.machineryTotal=this.machineryTotal;
        this.form.materialTotal=this.materialTotal;
        this.form.totalAmount=this.totalAmount;
        this.form.ysTotal=this.ysTotal;
        if (valid) {
          if (this.form.id != null) {
            updateFeeinfo(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addFeeinfo(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除费用管理编号为"' + ids + '"的数据项？').then(function() {
        return delFeeinfo(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$modal.confirm('是否确认导出所有费用管理数据项？').then(() => {
        this.exportLoading = true;
        return exportFeeinfo(queryParams);
      }).then(response => {
        this.$download.name(response.msg);
        this.exportLoading = false;
      }).catch(() => {});
    },
    treeHandler(node) {
      this.queryParams.categoryId=null;
      this.form.categoryId=null;
      this.form.categoryName=null;
      if(node.isLeaf){
        this.form.categoryId=node.data.id;
        this.form.categoryName=node.data.label;
        this.categoryRemark=node.data.category.remark;
        this.category=node.data.category;
      }
      this.queryParams.categoryId=node.data.id;
      this.getList();
      this.getBtnStatus();
    },
    // 文件提交处理
    submitUpload() {
      this.$refs.upload.submit();
      this.uploadFileDrawer=false;
    },
// 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
// 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.isUploading = false;
      this.form.filePath = response.url;
      this.$modal.msgSuccess(response.msg);
    },
    uploadFile(row){
      this.upload.url=this.upload.url+row.id;
      this.uploadFileDrawer=true;
      //初始化数据
      let query={};
      query.feeId=row.id;
      listFileinfo(query).then(response=>{
        let arry=[];
        if(response.rows){
          response.rows.map(m=>{
            let obj={};
            obj.name=m.fileName;
            obj.url=m.filePath;
            obj.id=m.id;
            arry.push(obj);
          })
        }
        this.upload.fileList=arry;
      })
    },
    handlePreview(file){
      var name = file.name;
      var url = file.url;
      const a = document.createElement('a')
      a.setAttribute('download', name)
      a.setAttribute('target', '_blank')
      a.setAttribute('href', url)
      a.click()
    },
    handleRemove(file){
      deleteFile(file.id).then(response=>{
        this.$modal.msgSuccess("删除成功");
      })
    },
    initForm(feeType){
      let category=this.category;
      if(feeType=='0'){
        this.form.unitId=category.costUnit;
        this.form.materialUnitId=category.clCostUnit;
        this.form.machineryUnitId=category.jxCostUnit;
      }else if(feeType=='1'){
        this.form.unitId=category.acwpUnit;
        this.form.materialUnitId=category.clAcwpUnit;
        this.form.machineryUnitId=category.jxAcwpUnit;
      }
    }
  }
};
</script>
